Skip to content

feat(panel): implement permissions system for panel#250

Merged
Akinator31 merged 3 commits intomainfrom
248-implement-permissions-system-for-panel
Nov 24, 2025
Merged

feat(panel): implement permissions system for panel#250
Akinator31 merged 3 commits intomainfrom
248-implement-permissions-system-for-panel

Conversation

@Akinator31
Copy link
Copy Markdown
Member

This pull request introduces significant improvements to the ticket bot API and permission handling in the Rustmail project. The main focus is on adding user session and permission checks, optimizing permission lookups with caching, and improving the handling of scheduled ticket closures. These changes enhance security by ensuring only authorized users can view or interact with tickets, and improve performance by reducing redundant permission queries.

Authentication and Permission Checks:

  • Added session-based authentication to the handle_tickets_bot endpoint, requiring a valid session_id cookie and verifying user permissions before returning ticket data. Only admins or users with the required category permissions can view tickets.
  • Introduced filtering of ticket lists based on user permissions, so non-admins only see tickets they are allowed to view.

Permission Caching and Utilities:

  • Added a new permissions_cache module using the moka crate for efficient, time-limited caching of admin status and category permissions, reducing redundant Discord API calls.
  • Implemented utility functions to check if a user is an admin/owner and to fetch and cache user permissions for ticket categories, including logic to determine if a user can view a channel.

Ticket Closure Improvements:

  • Added a format_duration helper to consistently format human-readable durations for ticket closures and warnings.
  • Improved scheduled closure logic to warn users when replacing an existing scheduled closure, showing the remaining time in a user-friendly format.

Code Quality and Refactoring:

  • Refactored SQL query handling for thread and message fetching to improve readability and maintainability.

Dependency Updates:

  • Added the moka crate to Cargo.toml for caching support.

These changes collectively improve both the security and performance of the ticket bot API, providing a better user experience and more robust permission management.

@Akinator31 Akinator31 self-assigned this Nov 24, 2025
@Akinator31 Akinator31 linked an issue Nov 24, 2025 that may be closed by this pull request
@Akinator31 Akinator31 merged commit 8b5c6ee into main Nov 24, 2025
6 checks passed
@Akinator31 Akinator31 deleted the 248-implement-permissions-system-for-panel branch November 24, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement permissions system for panel

1 participant